#include<cstdio>
#include<cstring>
using namespace std;
int a[8005];
int ans[8005],f=0;
int n,q;
inline int read(){
	int x=0,ch=getchar();
	while(ch<48||ch>57)
		ch=getchar();
	while(ch>47&&ch<58)
		x=(x<<3)+(x<<1)+(ch&15),ch=getchar();
	return x;
}
int main(){
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	n=read(),q=read();
	int maxn=0,maxnum=0,minn=1e9,minnum=0;
	for(int i=1;i<=n;++i){
		a[i]=read();
		if(a[i]>maxn){
			maxn=a[i];
			maxnum=1;
		}
		if(a[i]<minn){
			minn=a[i];
			minnum=1;
		}
		if(a[i]==maxn)
			maxnum++;
		if(a[i]==minn)
			minnum++;
	}
	int op,x,v;
	while(q--){
		op=read(),x=read();
		if(op==1){
			f=1;
			v=read();
			a[x]=v;
			if(v>maxn){
				maxn=v;
				maxnum=1;
			}
			if(v<minn){
				minn=v;
				minnum=1;
			}
			if(v==maxn)
				maxnum++;
			if(v==minn)
				minnum++;
		}
		else{
			if(f) memset(ans,0,sizeof(ans));
			if(ans[x]){
				printf("%d\n",ans[x]);
				continue;
			}
			if(a[x]==maxn&&maxnum==1){
				printf("1\n");
				continue;
			}
			if(a[x]==minn&&minnum==1){
				printf("%d\n",n);
				continue;
			}
			int w=1;
			for(int i=1;i<x;++i)
				if(a[i]<=a[x]) ++w;
			for(int i=x+1;i<=n;++i)
				if(a[i]<a[x]) ++w;
			ans[x]=w;
			f=0;
			printf("%d\n",w);
		}
	}
	return 0;
}
